#import <Foundation/Foundation.h>
#import <CoreLocation/CLLocation.h>


extern NSInteger compareAlarmTimes(id obj1, id obj2, void *context);

enum kPIEventAlarmType {
    kPIEventAlarmTypeNative,          // scheduled alarm from an application
    kPIEventAlarmTypeLocationArrive,
    kPIEventAlarmTypeLocationLeave,
    kPIEventAlarmTypeExtraAlarm,      // added alarm from the plugin
    kPIEventAlarmTypeExtraReminder,   // added reminder from the plugin
    kPIEventAlarmTypeAlarmIsActive    // alarm should be marked active
};


@interface PIAlarm : NSObject
{
    NSString* key;
    NSDate* date;
    NSTimeInterval relativeDate;
    kPIEventAlarmType type;
    BOOL fixedTime;
    
    NSString* location;
    CLLocation* coordinates;
}

@property (readonly, retain) NSString* key; 
@property (readonly, retain) NSDate* date; 
@property (readonly, assign) NSTimeInterval relativeDate; 
@property (readonly, assign) kPIEventAlarmType type; 
@property (assign, getter=isFixedTime) BOOL fixedTime; 

@property (readonly) NSString* location;
@property (readonly) CLLocation* coordinates;


+ (PIAlarm*)alarmWithKey:(NSString*)newKey date:(NSDate*)newDate type:(kPIEventAlarmType)newType;
+ (PIAlarm*)alarmWithKey:(NSString*)newKey relativeDate:(NSTimeInterval)newRelative baseDate:(NSDate*)newDate type:(kPIEventAlarmType)newType;
+ (PIAlarm*)alarmWithKey:(NSString*)newKey type:(kPIEventAlarmType)newType location:(NSString*)newLocation coordinates:(CLLocation*)newCoordinates;
+ (PIAlarm*)alarmWithKey:(NSString*)newKey relativeDate:(NSTimeInterval)newRelative baseDate:(NSDate*)newDate type:(kPIEventAlarmType)newType fixedTime:(BOOL)newFixedTime;

- (BOOL)isRelative;

- (void)expireAlarm;

@end


@interface NSArray (PIAlarm)

- (id)piAlarmForKey:(NSString*)key;
- (id)piAlarmForKey:(NSString*)key type:(kPIEventAlarmType)type;

@end
